Current File : //usr/lib/python3/dist-packages/twisted/python/__pycache__/_inotify.cpython-312.pyc |
�
Ϫ�f�
� �< � d Z ddlZddlZddlmZmZ ddlmZ G d� de� Z de
fd�Zd e
d
ee de
de
fd�Zd e
d
e
ddfd�Z
dej ddfd�Zej j# d� Zes ed� �ej( j+ e� Z ee� y)z�
Very low-level ctypes-based interface to Linux inotify(7).
ctypes and a version of libc which supports inotify system calls are
required.
� N)�Any�cast)�FilePathc � � e Zd ZdZy)�INotifyErrorzR
Unify all the possible exceptions that can be raised by the INotify API.
N)�__name__�
__module__�__qualname__�__doc__� � �9/usr/lib/python3/dist-packages/twisted/python/_inotify.pyr r s � �r
r �returnc �j � t t t j � � } | dk rt d� �| S )zO
Create an inotify instance and return the associated file descriptor.
r zINotify initialization error.)r �int�libc�inotify_initr )�fds r �initr s1 � �
�c�4�$�$�&� '�B� �A�v��:�;�;�
�Ir
r �path�maskc � � t t t j | |j � j
|� � }|dk rt
d|�d|�d�� �|S )a/
Add a watch for the given path to the inotify file descriptor, and return
the watch descriptor.
@param fd: The file descriptor returned by C{libc.inotify_init}.
@param path: The path to watch via inotify.
@param mask: Bitmask specifying the events that inotify should monitor.
r zFailed to add watch on 'z' - (�))r r r �inotify_add_watch�asBytesModer r )r r r �wds r �addr # sU � �
�c�4�)�)�"�d�.>�.>�.@�.E�.E�t�L� M�B� �A�v��5�d�X�U�2�&��J�K�K�
�Ir
r c �0 � t j | |� y)zM
Remove the given watch descriptor from the inotify file descriptor.
N)r �inotify_rm_watch)r r s r �remover 2 s � �0 ���"�b�!r
r c � � dD ] }t | |d� ��t d� � g | j _ t j
| j _ t j
t j
g| j _ t j
| j _ t j
t j t j g| j _ t j
| j _ y)z�
Initialize the module, checking if the expected APIs exist and setting the
argtypes and restype for C{inotify_init}, C{inotify_add_watch}, and
C{inotify_rm_watch}.
)r r r Nzlibc6 2.4 or higher needed)�getattr�ImportErrorr �argtypes�ctypes�c_int�restyper �c_char_p�c_uint32r )r �functions r �initializeModuler+ M s� � � N� <���4��4�(�0��:�;�;�<� "$�D���� &���D����&,�l�l�F�L�L�%A�D���"�$*�L�L�D���!�'-�|�|�V�_�_�f�o�o�&V�D���#�%+�\�\�D���"r
�czCan't find C library.)r r% �ctypes.util�typingr r �twisted.python.filepathr � Exceptionr r r r r �CDLLr+ �util�find_library�namer# �cdll�LoadLibraryr r r
r �<module>r7 s� ��
� � � � ,��9� ��c� ��C� �x��}� �C� �C� �"�s� "�� "�� "�62�6�;�;� 2�4� 2�&